﻿using ConfExpert.Forms.Base;
using DevTeam;
using System;

namespace ConfExpert.Forms.SatinAlma
{
    public partial class MergeAlisFaturasi : XForm
    {
        public MergeAlisFaturasi()
        {
            InitializeComponent();
        }

        private void MergeAlisFaturasi_Load(object sender, EventArgs e)
        {
            gridView1.Init("GetAlisFaturasiDupl");
            gridView1.AddDetailGrid(gridView2, "InvoiceNo,GonderenId,Yil");

            gridView1.AddSummary();
            gridView2.AddSummary();

            gridView1.BestFitColumns();
            gridView2.BestFitColumns();

            gridView1.FocusedRowChanged += gridView1_FocusedRowChanged;
            splitContainerControl1.AutoSize();

            GridManager gm = GridManager.GetManager(gridView2);
            gm.GridMenu.AddMenu("Birleştir", Merge);
        }


        private void Merge(object sender, EventArgs e)
        {
            string ids = gridView2.GetSelectedValues("AlisFaturasiId");
            ExecuteNonQuery("MergeAlisFaturasi", ids);
        }

        void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            gridView2.ShowOnlyNonblankColumns(false);
            gridView2.ShowOnlyNonblankColumns(true);
            gridView2.BestFitColumns();
        }
    }
}
